using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BuffRapidFire : BuffBase{

	public BuffRapidFire(BuffSlot slot,Mob mob):base(slot,mob){	}

	protected override void SubscribeEvents() {
		base.SubscribeEvents();
		Weapon.Shooting+=ShootingEventHandler;
		Weapon.BurstDeciding+=BurstDecidingEventHandler;
	}
	protected override void UnsubscribeEvents() {
		base.UnsubscribeEvents();
		Weapon.Shooting-=ShootingEventHandler;
		Weapon.BurstDeciding-=BurstDecidingEventHandler;
	}
	
	
	void ShootingEventHandler(object sender,ShootEventArgs e){
		if(e.senderMob!=mob) return;
		e.stat.cooldownTime.AddDivideAdd(0.1f*Mathf.Ceil(stacks),1);
	}
	void BurstDecidingEventHandler(object sender,BurstDecidingEventArgs e) {
		if(e.senderMob!=mob) return;
		e.stat.cooldownTime.AddDivideAdd(0.1f*Mathf.Ceil(stacks),1);
		_stacks-=1;
	}

	protected override void Update() {
		base.Update();
		_stacks-=Time.deltaTime*mob.localTimeScale;
		if(_stacks<0) slot.RemoveBuff(GetType());
	}
}